aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/pkg/sentry/value.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/pkg/sentry/value.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/pkg/sentry/value.zig')
-rw-r--r--vendor/libghostty-vt/pkg/sentry/value.zig75
1 files changed, 75 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/pkg/sentry/value.zig b/vendor/libghostty-vt/pkg/sentry/value.zig
new file mode 100644
index 00000000..0c839ecd
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/sentry/value.zig
@@ -0,0 +1,75 @@
+const std = @import("std");
+const assert = std.debug.assert;
+const c = @import("c.zig").c;
+const Level = @import("level.zig").Level;
+
+/// sentry_value_t
+pub const Value = struct {
+ /// The underlying value. This is a union that could be represented with
+ /// an extern union but I don't want to risk C ABI issues so we wrap it
+ /// in a struct.
+ value: c.sentry_value_t,
+
+ pub fn initMessageEvent(
+ level: Level,
+ logger: ?[]const u8,
+ message: []const u8,
+ ) Value {
+ return .{ .value = c.sentry_value_new_message_event_n(
+ @intFromEnum(level),
+ if (logger) |v| v.ptr else null,
+ if (logger) |v| v.len else 0,
+ message.ptr,
+ message.len,
+ ) };
+ }
+
+ pub fn initObject() Value {
+ return .{ .value = c.sentry_value_new_object() };
+ }
+
+ pub fn initString(value: []const u8) Value {
+ return .{ .value = c.sentry_value_new_string_n(value.ptr, value.len) };
+ }
+
+ pub fn initBool(value: bool) Value {
+ return .{ .value = c.sentry_value_new_bool(@intFromBool(value)) };
+ }
+
+ pub fn initInt32(value: i32) Value {
+ return .{ .value = c.sentry_value_new_int32(value) };
+ }
+
+ pub fn decref(self: Value) void {
+ c.sentry_value_decref(self.value);
+ }
+
+ pub fn incref(self: Value) Value {
+ c.sentry_value_incref(self.value);
+ }
+
+ pub fn isNull(self: Value) bool {
+ return c.sentry_value_is_null(self.value) != 0;
+ }
+
+ /// sentry_value_set_by_key_n
+ pub fn set(self: Value, key: []const u8, value: Value) void {
+ _ = c.sentry_value_set_by_key_n(
+ self.value,
+ key.ptr,
+ key.len,
+ value.value,
+ );
+ }
+
+ /// sentry_value_set_by_key_n
+ pub fn get(self: Value, key: []const u8) ?Value {
+ const val: Value = .{ .value = c.sentry_value_get_by_key_n(
+ self.value,
+ key.ptr,
+ key.len,
+ ) };
+ if (val.isNull()) return null;
+ return val;
+ }
+};