Skip to content

Commit 5020a28

Browse files
committed
more comments
1 parent fa6141b commit 5020a28

32 files changed

+896
-2
lines changed

examples/shared/demo_runner.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,51 @@ const time_compat = @import("time_compat");
44
const env_compat = @import("env_compat");
55
const webui = @import("webui");
66

7+
/// Enumerates example kind values.
78
pub const ExampleKind = enum {
9+
/// Selects `minimal`.
810
minimal,
11+
/// Selects `call_js_from_zig`.
912
call_js_from_zig,
13+
/// Selects `call_zig_from_js`.
1014
call_zig_from_js,
15+
/// Selects `bidirectional_rpc`.
1116
bidirectional_rpc,
17+
/// Selects `serve_folder`.
1218
serve_folder,
19+
/// Selects `vfs`.
1320
vfs,
21+
/// Selects `public_network`.
1422
public_network,
23+
/// Selects `multi_client`.
1524
multi_client,
25+
/// Selects `chatgpt_api`.
1626
chatgpt_api,
27+
/// Selects `custom_web_server`.
1728
custom_web_server,
29+
/// Selects `react`.
1830
react,
31+
/// Selects `frameless`.
1932
frameless,
33+
/// Selects `fancy_window`.
2034
fancy_window,
35+
/// Selects `translucent_rounded`.
2136
translucent_rounded,
37+
/// Selects `text_editor`.
2238
text_editor,
39+
/// Selects `minimal_oop`.
2340
minimal_oop,
41+
/// Selects `call_js_oop`.
2442
call_js_oop,
43+
/// Selects `call_oop_from_js`.
2544
call_oop_from_js,
45+
/// Selects `serve_folder_oop`.
2646
serve_folder_oop,
47+
/// Selects `vfs_oop`.
2748
vfs_oop,
2849
};
2950

51+
/// Stores rpc methods.
3052
pub const rpc_methods = struct {
3153
/// Returns a stable ping response used by the shared example frontend.
3254
pub fn ping() []const u8 {

src/backends/linux_browser_host.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ const env_compat = @import("env_compat");
44
const window_style_types = @import("../root/window_style.zig");
55
const linux = std.os.linux;
66

7+
/// Captures launch result.
78
pub const LaunchResult = struct {
9+
/// Stores the pid.
810
pid: i64,
11+
/// Whether is child process.
912
is_child_process: bool = true,
1013
};
1114

src/backends/linux_webview/symbols.zig

Lines changed: 112 additions & 0 deletions
Large diffs are not rendered by default.

src/backends/linux_webview_host.zig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,49 @@ const Command = union(enum) {
3838
}
3939
};
4040

41+
/// Owns platform-native host state and thread-affine resources.
4142
pub const Host = struct {
43+
/// Allocates host-owned buffers and runtime state.
4244
allocator: std.mem.Allocator,
45+
/// Stores the current native window title.
4346
title: []u8,
47+
/// Stores the last applied window style.
4448
style: WindowStyle,
49+
/// Stores the runtime target.
4550
runtime_target: RuntimeTarget = .webview,
4651

52+
/// Stores the mutex.
4753
mutex: thread_compat.Mutex = .{},
54+
/// Stores the queue.
4855
queue: Queue,
4956

57+
/// Stores the symbols.
5058
symbols: ?Symbols = null,
59+
/// Stores the window widget.
5160
window_widget: ?*common.GtkWidget = null,
61+
/// Stores the content widget.
5262
content_widget: ?*common.GtkWidget = null,
63+
/// Stores the webview.
5364
webview: ?*common.WebKitWebView = null,
65+
/// Stores the icon temp path.
5466
icon_temp_path: ?[]u8 = null,
5567

68+
/// Stores the ui ready.
5669
ui_ready: bool = false,
70+
/// Stores the closed.
5771
closed: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
72+
/// Stores the shutdown requested.
5873
shutdown_requested: bool = false,
5974

6075
/// Start.
6176
pub fn start(
77+
/// Allocates host-owned buffers and runtime state.
6278
allocator: std.mem.Allocator,
79+
/// Stores the current native window title.
6380
title: []const u8,
81+
/// Stores the last applied window style.
6482
style: WindowStyle,
83+
/// Stores the runtime target.
6584
runtime_target: RuntimeTarget,
6685
) !*Host {
6786
if (!linuxNativeToolkitSupported()) return error.NativeBackendUnavailable;

src/backends/macos_browser_host.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ const std = @import("std");
22
const env_compat = @import("env_compat");
33
const window_style_types = @import("../root/window_style.zig");
44

5+
/// Captures launch result.
56
pub const LaunchResult = struct {
7+
/// Stores the pid.
68
pid: i64,
9+
/// Whether is child process.
710
is_child_process: bool = true,
811
};
912

src/backends/macos_webview/bindings.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ pub const SelRegisterNameFn = *const fn ([*:0]const u8) callconv(.c) SEL;
77
pub const ObjcAutoreleasePoolPushFn = *const fn () callconv(.c) ?*anyopaque;
88
pub const ObjcAutoreleasePoolPopFn = *const fn (?*anyopaque) callconv(.c) void;
99

10+
/// Stores dynamically resolved native symbol bindings.
1011
pub const Symbols = struct {
12+
/// Binds `objc` from the native runtime.
1113
objc: std.DynLib,
14+
/// Binds `appkit` from the native runtime.
1215
appkit: std.DynLib,
16+
/// Binds `webkit` from the native runtime.
1317
webkit: std.DynLib,
1418

19+
/// Binds `objc_get_class` from the native runtime.
1520
objc_get_class: ObjcGetClassFn,
21+
/// Binds `sel_register_name` from the native runtime.
1622
sel_register_name: SelRegisterNameFn,
23+
/// Binds `objc_msg_send` from the native runtime.
1724
objc_msg_send: *const anyopaque,
25+
/// Binds `autorelease_pool_push` from the native runtime.
1826
autorelease_pool_push: ObjcAutoreleasePoolPushFn,
27+
/// Binds `autorelease_pool_pop` from the native runtime.
1928
autorelease_pool_pop: ObjcAutoreleasePoolPopFn,
2029

2130
/// Loads the platform symbols.

src/backends/macos_webview_host.zig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,35 @@ const NSRect = extern struct {
4040
size: NSSize,
4141
};
4242

43+
/// Owns platform-native host state and thread-affine resources.
4344
pub const Host = struct {
45+
/// Allocates host-owned buffers and runtime state.
4446
allocator: std.mem.Allocator,
47+
/// Stores the current native window title.
4548
title: []u8,
49+
/// Stores the last applied window style.
4650
style: WindowStyle,
51+
/// Stores the ui ready.
4752
ui_ready: bool = false,
53+
/// Stores the closed.
4854
closed: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
4955

56+
/// Stores the symbols.
5057
symbols: ?objc.Symbols = null,
5158

59+
/// Stores the ns app.
5260
ns_app: ?*anyopaque = null,
61+
/// Stores the ns window.
5362
ns_window: ?*anyopaque = null,
63+
/// Stores the wk webview.
5464
wk_webview: ?*anyopaque = null,
65+
/// Stores the app icon image.
5566
app_icon_image: ?*anyopaque = null,
67+
/// Stores the kiosk active.
5668
kiosk_active: bool = false,
69+
/// Stores the explicit hidden.
5770
explicit_hidden: bool = false,
71+
/// Stores the owner thread id.
5872
owner_thread_id: std.Thread.Id = undefined,
5973

6074
/// Starts the native Cocoa/WKWebView host on the current thread.

src/backends/windows_browser_host.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ const std = @import("std");
22
const env_compat = @import("env_compat");
33
const window_style_types = @import("../root/window_style.zig");
44

5+
/// Captures launch result.
56
pub const LaunchResult = struct {
7+
/// Stores the pid.
68
pid: i64,
9+
/// Whether is child process.
710
is_child_process: bool = true,
811
};
912

@@ -187,7 +190,7 @@ test "windows show window command mapping is stable" {
187190
}
188191

189192
test "powershell browser launch script does not request hidden window style" {
190-
const script = try buildPowershellLaunchScript(std.testing.allocator, "C:\\Browser\\browser.exe", &.{ "http://127.0.0.1:4020/" });
193+
const script = try buildPowershellLaunchScript(std.testing.allocator, "C:\\Browser\\browser.exe", &.{"http://127.0.0.1:4020/"});
191194
defer std.testing.allocator.free(script);
192195
try std.testing.expect(std.mem.indexOf(u8, script, "-WindowStyle Hidden") == null);
193196
try std.testing.expect(std.mem.indexOf(u8, script, "Start-Process") != null);

src/backends/windows_webview/bindings.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,11 @@ extern "kernel32" fn LoadLibraryW(lpLibFileName: win.LPCWSTR) callconv(.winapi)
255255
extern "kernel32" fn FreeLibrary(hLibModule: win.HMODULE) callconv(.winapi) win.BOOL;
256256
extern "kernel32" fn GetProcAddress(hModule: win.HMODULE, lpProcName: [*:0]const u8) callconv(.winapi) ?*const anyopaque;
257257

258+
/// Stores dynamically resolved native symbol bindings.
258259
pub const Symbols = struct {
260+
/// Binds `loader` from the native runtime.
259261
loader: win.HMODULE,
262+
/// Binds `create_environment` from the native runtime.
260263
create_environment: CreateCoreWebView2EnvironmentWithOptionsFn,
261264

262265
/// Loads the platform symbols.

src/backends/windows_webview_host.zig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,37 +193,63 @@ extern "user32" fn DestroyIcon(win.HICON) callconv(.winapi) win.BOOL;
193193
extern "gdi32" fn CreateRoundRectRgn(i32, i32, i32, i32, i32, i32) callconv(.winapi) ?*anyopaque;
194194
extern "gdi32" fn DeleteObject(?*anyopaque) callconv(.winapi) win.BOOL;
195195

196+
/// Owns platform-native host state and thread-affine resources.
196197
pub const Host = struct {
198+
/// Allocates host-owned buffers and runtime state.
197199
allocator: std.mem.Allocator,
200+
/// Stores the current native window title.
198201
title: []u8,
202+
/// Stores the last applied window style.
199203
style: WindowStyle,
200204

205+
/// Stores the mutex.
201206
mutex: thread_compat.Mutex = .{},
207+
/// Stores the queue.
202208
queue: std.array_list.Managed(Command),
209+
/// Stores the owner thread id.
203210
owner_thread_id: std.Thread.Id = undefined,
204211

212+
/// Stores the startup done.
205213
startup_done: bool = false,
214+
/// Stores the startup error.
206215
startup_error: ?anyerror = null,
216+
/// Stores the ui ready.
207217
ui_ready: bool = false,
218+
/// Stores the closed.
208219
closed: std.atomic.Value(bool) = std.atomic.Value(bool).init(false),
220+
/// Stores the shutdown requested.
209221
shutdown_requested: bool = false,
222+
/// Stores the pending async callbacks.
210223
pending_async_callbacks: usize = 0,
211224

225+
/// Stores the instance.
212226
instance: ?win.HINSTANCE = null,
227+
/// Stores the class registered.
213228
class_registered: bool = false,
229+
/// Stores the hwnd.
214230
hwnd: ?win.HWND = null,
231+
/// Stores the window icon.
215232
window_icon: ?win.HICON = null,
233+
/// Stores the window destroy started.
216234
window_destroy_started: bool = false,
217235

236+
/// Stores the symbols.
218237
symbols: ?wv2.Symbols = null,
238+
/// Stores the com initialized.
219239
com_initialized: bool = false,
220240

241+
/// Stores the environment.
221242
environment: ?*wv2.ICoreWebView2Environment = null,
243+
/// Stores the controller.
222244
controller: ?*wv2.ICoreWebView2Controller = null,
245+
/// Stores the webview.
223246
webview: ?*wv2.ICoreWebView2 = null,
247+
/// Stores the title changed token.
224248
title_changed_token: wv2.EventRegistrationToken = .{ .value = 0 },
249+
/// Stores the title handler attached.
225250
title_handler_attached: bool = false,
226251

252+
/// Stores the pending url.
227253
pending_url: ?[]u8 = null,
228254

229255
/// Start.

0 commit comments

Comments
 (0)