Skip to content

Commit

Permalink
update with zig master changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DerryAlex committed Nov 2, 2024
1 parent 27c6066 commit 9c3d9b4
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 244 deletions.
6 changes: 3 additions & 3 deletions examples/application/example_app.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ pub const ExampleApp = extern struct {
pub const signalConnect = Ext.signalConnect;

pub const Override = struct {
pub fn activate(arg_app: *GApplication) callconv(.C) void {
pub fn activate(arg_app: *GApplication) callconv(.c) void {
const self = arg_app.tryInto(ExampleApp).?;
var win = ExampleAppWindow.new(self);
win.__call("present", .{});
}

pub fn open(arg_app: *GApplication, arg_files: [*]*File, arg_n_files: i32, arg_hint: [*:0]const u8) callconv(.C) void {
pub fn open(arg_app: *GApplication, arg_files: [*]*File, arg_n_files: i32, arg_hint: [*:0]const u8) callconv(.c) void {
var self = arg_app.tryInto(ExampleApp).?;
_ = arg_hint;
const windows = self.__call("getWindows", .{});
Expand All @@ -58,7 +58,7 @@ pub const ExampleApp = extern struct {
win.__call("present", .{});
}

pub fn startup(arg_app: *GApplication) callconv(.C) void {
pub fn startup(arg_app: *GApplication) callconv(.c) void {
var self = arg_app.tryInto(ExampleApp).?;
var action_preferences = SimpleAction.new("preferences", null);
defer action_preferences.__call("unref", .{});
Expand Down
2 changes: 1 addition & 1 deletion examples/application/example_app_prefs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub const ExampleAppPrefs = extern struct {
pub const signalConnect = Ext.signalConnect;

pub const Override = struct {
pub fn dispose(arg_object: *Object) callconv(.C) void {
pub fn dispose(arg_object: *Object) callconv(.c) void {
var self = arg_object.tryInto(ExampleAppPrefs).?;
self.private.settings.__call("unref", .{});
self.__call("disposeTemplate", .{ExampleAppPrefs.gType()});
Expand Down
6 changes: 3 additions & 3 deletions examples/application/example_app_window.zig
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub const ExampleAppWindowClass = extern struct {
});
}

pub fn searchTextChanged(entry: *Entry, self: *ExampleAppWindow) callconv(.C) void {
pub fn searchTextChanged(entry: *Entry, self: *ExampleAppWindow) callconv(.c) void {
const text = entry.__call("getText", .{});
if (text[0] == 0) return;
var tab = self.stack.getVisibleChild().?.tryInto(ScrolledWindow).?;
Expand All @@ -95,7 +95,7 @@ pub const ExampleAppWindowClass = extern struct {
}
}

pub fn visibleChildChanged(stack: *Stack, _: *ParamSpec, self: *ExampleAppWindow) callconv(.C) void {
pub fn visibleChildChanged(stack: *Stack, _: *ParamSpec, self: *ExampleAppWindow) callconv(.c) void {
if (stack.__call("inDestruction", .{})) return;
self.searchbar.setSearchMode(false);
self.updateWords();
Expand Down Expand Up @@ -127,7 +127,7 @@ pub const ExampleAppWindow = extern struct {
pub const signalConnect = Ext.signalConnect;

pub const Override = struct {
pub fn dispose(arg_object: *Object) callconv(.C) void {
pub fn dispose(arg_object: *Object) callconv(.c) void {
var self = arg_object.tryInto(ExampleAppWindow).?;
self.settings.__call("unref", .{});
self.__call("disposeTemplate", .{ExampleAppWindow.gType()});
Expand Down
10 changes: 5 additions & 5 deletions examples/custom/custom_button.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var _signals: [1]u32 = undefined;

pub const CustomButtonClass = extern struct {
parent_class: ButtonClass,
zero_reached: ?*const fn (self: *CustomButton) callconv(.C) void,
zero_reached: ?*const fn (self: *CustomButton) callconv(.c) void,

pub var parent_class_ptr: ?*ButtonClass = null;

Expand Down Expand Up @@ -68,7 +68,7 @@ pub const CustomButton = extern struct {
pub const signalConnect = Ext.signalConnect;

pub const Override = struct {
pub fn set_property(arg_object: *Object, arg_property_id: u32, arg_value: *Value, _: *ParamSpec) callconv(.C) void {
pub fn set_property(arg_object: *Object, arg_property_id: u32, arg_value: *Value, _: *ParamSpec) callconv(.c) void {
var self = arg_object.tryInto(CustomButton).?;
switch (@as(Properties, @enumFromInt(arg_property_id))) {
.Number => {
Expand All @@ -77,7 +77,7 @@ pub const CustomButton = extern struct {
}
}

pub fn get_property(arg_object: *Object, arg_property_id: u32, arg_value: *Value, _: *ParamSpec) callconv(.C) void {
pub fn get_property(arg_object: *Object, arg_property_id: u32, arg_value: *Value, _: *ParamSpec) callconv(.c) void {
var self = arg_object.tryInto(CustomButton).?;
switch (@as(Properties, @enumFromInt(arg_property_id))) {
.Number => {
Expand All @@ -86,14 +86,14 @@ pub const CustomButton = extern struct {
}
}

pub fn constructed(arg_object: *Object) callconv(.C) void {
pub fn constructed(arg_object: *Object) callconv(.c) void {
var self = arg_object.tryInto(CustomButton).?;
const p_class: *gobject.ObjectClass = @ptrCast(Class.parent_class_ptr);
p_class.constructed.?(arg_object);
_ = self.__call("bindProperty", .{ "number", self.into(Object), "label", .{ .sync_create = true } });
}

pub fn clicked(arg_button: *Button) callconv(.C) void {
pub fn clicked(arg_button: *Button) callconv(.c) void {
var self = arg_button.tryInto(CustomButton).?;
const decremented_number = self.private.number - 1;
self.setNumber(decremented_number);
Expand Down
24 changes: 12 additions & 12 deletions manual/core.zig
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ const NopClosure = struct {
pub fn new(_: anytype, _: anytype) !*Self {
return undefined;
}
pub fn invoke() callconv(.C) void {}
pub fn invoke() callconv(.c) void {}
pub fn setOnce(_: *Self) void {}
pub fn deinit(_: *Self) callconv(.C) void {}
pub fn deinit(_: *Self) callconv(.c) void {}
pub inline fn c_closure(_: *Self) ?*anyopaque {
return null;
}
Expand Down Expand Up @@ -459,7 +459,7 @@ pub fn ZigClosure(comptime FnPtr: type, comptime Args: type, comptime signature:
}

/// Invokes the closure, i.e. executes the callback represented by the closure
pub fn invoke(...) callconv(.C) signature[0] {
pub fn invoke(...) callconv(.c) signature[0] {
var va_list = @cVaStart();
var args: std.meta.Tuple(signature[1..]) = undefined;
inline for (1..signature.len) |i| {
Expand Down Expand Up @@ -490,7 +490,7 @@ pub fn ZigClosure(comptime FnPtr: type, comptime Args: type, comptime signature:
}

/// Free its memory
pub fn deinit(self: *Self) callconv(.C) void {
pub fn deinit(self: *Self) callconv(.c) void {
std.heap.c_allocator.destroy(self);
}

Expand Down Expand Up @@ -519,14 +519,14 @@ pub fn zig_closure(handler: anytype, args: anytype, comptime signature: []const
/// Creates a new closure which invokes `callback_func` with `user_data` as the last parameter.
/// `destroy_data` will be called as a finalize notifier on the GClosure.
fn cclosureNew(callback_func: gobject.Callback, user_data: ?*anyopaque, destroy_data: gobject.ClosureNotify) *gobject.Closure {
const g_cclosure_new = @extern(*const fn (gobject.Callback, ?*anyopaque, gobject.ClosureNotify) callconv(.C) *gobject.Closure, .{ .name = "g_cclosure_new" });
const g_cclosure_new = @extern(*const fn (gobject.Callback, ?*anyopaque, gobject.ClosureNotify) callconv(.c) *gobject.Closure, .{ .name = "g_cclosure_new" });
return g_cclosure_new(callback_func, user_data, destroy_data);
}

/// Creates a new closure which invokes `callback_func` with `user_data` as the first parameter.
/// `destroy_data` will be called as a finalize notifier on the GClosure.
fn cclosureNewSwap(callback_func: gobject.Callback, user_data: ?*anyopaque, destroy_data: gobject.ClosureNotify) *gobject.Closure {
const g_cclosure_new_swap = @extern(*const fn (gobject.Callback, ?*anyopaque, gobject.ClosureNotify) callconv(.C) *gobject.Closure, .{ .name = "g_cclosure_new_swap" });
const g_cclosure_new_swap = @extern(*const fn (gobject.Callback, ?*anyopaque, gobject.ClosureNotify) callconv(.c) *gobject.Closure, .{ .name = "g_cclosure_new_swap" });
return g_cclosure_new_swap(callback_func, user_data, destroy_data);
}

Expand All @@ -544,7 +544,7 @@ fn objectNewWithProperties(object_type: Type, names: ?[][*:0]const u8, values: ?
} else {
std.debug.assert(values == null);
}
const g_object_new_with_properties = @extern(*const fn (Type, c_uint, ?[*][*:0]const u8, ?[*]gobject.Value) callconv(.C) *gobject.Object, .{ .name = "g_object_new_with_properties" });
const g_object_new_with_properties = @extern(*const fn (Type, c_uint, ?[*][*:0]const u8, ?[*]gobject.Value) callconv(.c) *gobject.Object, .{ .name = "g_object_new_with_properties" });
return g_object_new_with_properties(object_type, if (names) |some| @intCast(some.len) else 0, if (names) |some| some.ptr else null, if (values) |some| some.ptr else null);
}

Expand Down Expand Up @@ -575,7 +575,7 @@ pub fn newObject(comptime T: type, properties: anytype) *T {
/// Creates a new signal. (This is usually done in the class initializer.)
fn signalNewv(signal_name: [*:0]const u8, itype: Type, signal_flags: gobject.SignalFlags, class_closure: ?*gobject.Closure, accumulator: anytype, accu_data: anytype, c_marshaller: ?gobject.ClosureMarshal, return_type: Type, param_types: ?[]Type) u32 {
var accumulator_closure = zig_closure(accumulator, accu_data, &.{ bool, *gobject.SignalInvocationHint, *gobject.Value, *gobject.Value });
const g_signal_newv = @extern(*const fn ([*:0]const u8, Type, gobject.SignalFlags, ?*gobject.Closure, ?gobject.SignalAccumulator, ?*anyopaque, ?gobject.ClosureMarshal, Type, c_uint, ?[*]Type) callconv(.C) c_uint, .{ .name = "g_signal_newv" });
const g_signal_newv = @extern(*const fn ([*:0]const u8, Type, gobject.SignalFlags, ?*gobject.Closure, ?gobject.SignalAccumulator, ?*anyopaque, ?gobject.ClosureMarshal, Type, c_uint, ?[*]Type) callconv(.c) c_uint, .{ .name = "g_signal_newv" });
return g_signal_newv(signal_name, itype, signal_flags, class_closure, @ptrCast(accumulator_closure.c_closure()), accumulator_closure.c_data(), c_marshaller, return_type, if (param_types) |some| @intCast(some.len) else 0, if (param_types) |some| some.ptr else null);
}

Expand Down Expand Up @@ -649,7 +649,7 @@ pub fn registerType(comptime Object: type, name: [*:0]const u8, flags: gobject.T
}
const Class: type = Object.Class;
const class_init = struct {
fn trampoline(class: *Class) callconv(.C) void {
fn trampoline(class: *Class) callconv(.c) void {
if (typeTag(Object).private_offset != 0) {
_ = gobject.typeClassAdjustPrivateOffset(class, &typeTag(Object).private_offset);
}
Expand All @@ -669,7 +669,7 @@ pub fn registerType(comptime Object: type, name: [*:0]const u8, flags: gobject.T
}
}.trampoline;
const instance_init = struct {
fn trampoline(self: *Object) callconv(.C) void {
fn trampoline(self: *Object) callconv(.c) void {
if (comptime @hasDecl(Object, "Private")) {
self.private = @ptrFromInt(@as(usize, @bitCast(@as(isize, @bitCast(@intFromPtr(self))) + typeTag(Object).private_offset)));
init(Object.Private, self.private);
Expand Down Expand Up @@ -720,7 +720,7 @@ fn classOverride(comptime Class: type, comptime Override: type, class: *Class) v

fn interfaceOverride(comptime Interface: type, comptime Override: type, type_id: Type) void {
const interface_init = struct {
pub fn trampoline(interface: *Interface) callconv(.C) void {
pub fn trampoline(interface: *Interface) callconv(.c) void {
inline for (comptime std.meta.declarations(Override)) |decl| {
if (@hasField(Interface, decl.name)) {
@field(interface, decl.name) = @field(Override, decl.name);
Expand Down Expand Up @@ -780,7 +780,7 @@ fn checkOverride(comptime Object: type, comptime Override: type) void {
/// Registers a new static type
pub fn registerInterface(comptime Interface: type, name: [*:0]const u8) Type {
const class_init = struct {
pub fn trampoline(self: *Interface) callconv(.C) void {
pub fn trampoline(self: *Interface) callconv(.c) void {
if (comptime @hasDecl(Interface, "properties")) {
for (Interface.properties()) |property| {
gobject.Object.interfaceInstallProperty(@ptrCast(self), property);
Expand Down
2 changes: 1 addition & 1 deletion src/core_min.zig
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub const TypeInstance = extern struct {
};

pub fn typeCheckInstanceIsA(_instance: *TypeInstance, _iface_type: Type) bool {
const cFn = @extern(*const fn (*TypeInstance, Type) callconv(.C) bool, .{ .name = "g_type_check_instance_is_a" });
const cFn = @extern(*const fn (*TypeInstance, Type) callconv(.c) bool, .{ .name = "g_type_check_instance_is_a" });
const ret = cFn(_instance, _iface_type);
return ret;
}
Expand Down
20 changes: 10 additions & 10 deletions src/gi-ext.zig
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub const CallableInfoExt = struct {
/// Specifiers:
/// - e: print `(arg_names...: arg_types...) return_type`
/// - o: print `(arg_types...) return_type`
/// - c: addtionally print `callconv(.C)`
/// - c: addtionally print `callconv(.c)`
pub fn format(self_immut: *const CallableInfo, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: std.io.AnyWriter) anyerror!void {
_ = options;
const self: *CallableInfo = @constCast(self_immut);
Expand Down Expand Up @@ -303,7 +303,7 @@ pub const CallableInfoExt = struct {
try writer.writeAll(") ");
if (type_annotation != .disable) {
if (c_callconv) {
try writer.writeAll("callconv(.C) ");
try writer.writeAll("callconv(.c) ");
}
if (self.skipReturn() and !emit_abi) {
try writer.writeAll("void");
Expand Down Expand Up @@ -334,7 +334,7 @@ pub const CallableInfoExt = struct {
};

pub const CallbackInfoExt = struct {
/// Print `*const fn(arg_names...: arg_types...) callconv(.C) return_type`
/// Print `*const fn(arg_names...: arg_types...) callconv(.c) return_type`
pub fn format(self_immut: *CallbackInfo, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: std.io.AnyWriter) anyerror!void {
_ = options;
const self: *CallbackInfo = @constCast(self_immut);
Expand All @@ -350,12 +350,12 @@ pub const CallbackInfoExt = struct {

pub const ConstantInfoExt = struct {
pub fn freeValue(self: *ConstantInfo, value: *gi.Argument) void {
const cFn = @extern(*const fn (*BaseInfo, *gi.Argument) callconv(.C) void, .{ .name = "gi_constant_info_free_value" });
const cFn = @extern(*const fn (*BaseInfo, *gi.Argument) callconv(.c) void, .{ .name = "gi_constant_info_free_value" });
_ = cFn(self.into(BaseInfo), value);
}

pub fn getValue(self: *ConstantInfo, value: *gi.Argument) c_int {
const cFn = @extern(*const fn (*BaseInfo, *gi.Argument) callconv(.C) c_int, .{ .name = "gi_constant_info_get_value" });
const cFn = @extern(*const fn (*BaseInfo, *gi.Argument) callconv(.c) c_int, .{ .name = "gi_constant_info_get_value" });
const ret = cFn(self.into(BaseInfo), value);
return ret;
}
Expand Down Expand Up @@ -724,7 +724,7 @@ pub const FunctionInfoExt = struct {
\\(_texts: []u8) []u8 {
\\ const _text = _texts.ptr;
\\ var _out_len: u64 = @intCast(_texts.len);
\\ const cFn = @extern(*const fn ([*]u8, *u64) callconv(.C) [*]u8, .{ .name = "g_base64_decode_inplace" });
\\ const cFn = @extern(*const fn ([*]u8, *u64) callconv(.c) [*]u8, .{ .name = "g_base64_decode_inplace" });
\\ const ret = cFn(_text, &_out_len);
\\ return ret[0.._out_len];
\\}
Expand All @@ -736,7 +736,7 @@ pub const FunctionInfoExt = struct {
if (std.mem.eql(u8, "g_base64_encode_close", func_symbol)) {
try writer.writeAll(
\\(_break_lines: bool, _out: [*]u8, _state: *i32, _save: *i32) u64 {
\\ const cFn = @extern(*const fn (bool, [*]u8, *i32, *i32) callconv(.C) u64, .{ .name = "g_base64_encode_close" });
\\ const cFn = @extern(*const fn (bool, [*]u8, *i32, *i32) callconv(.c) u64, .{ .name = "g_base64_encode_close" });
\\ const ret = cFn(_break_lines, _out, _state, _save);
\\ return ret;
\\}
Expand All @@ -749,7 +749,7 @@ pub const FunctionInfoExt = struct {
\\(_ins: []u8, _break_lines: bool, _out: [*]u8, _state: *i32, _save: *i32) u64 {
\\ const _in = _ins.ptr;
\\ const _len: u64 = @intCast(_ins.len);
\\ const cFn = @extern(*const fn ([*]u8, u64, bool, [*]u8, *i32, *i32) callconv(.C) u64, .{ .name = "g_base64_encode_step" });
\\ const cFn = @extern(*const fn ([*]u8, u64, bool, [*]u8, *i32, *i32) callconv(.c) u64, .{ .name = "g_base64_encode_step" });
\\ const ret = cFn(_in, _len, _break_lines, _out, _state, _save);
\\ return ret;
\\}
Expand All @@ -763,7 +763,7 @@ pub const FunctionInfoExt = struct {
\\(self: *ListStore, _position: u32, _n_removals: u32, _additionss: []*gobject.Object) void {
\\ const _additions = _additionss.ptr;
\\ const _n_additions: u32 = @intCast(_additionss.len);
\\ const cFn = @extern(*const fn (*ListStore, u32, u32, [*]*gobject.Object, u32) callconv(.C) void, .{ .name = "g_list_store_splice" });
\\ const cFn = @extern(*const fn (*ListStore, u32, u32, [*]*gobject.Object, u32) callconv(.c) void, .{ .name = "g_list_store_splice" });
\\ const ret = cFn(self, _position, _n_removals, _additions, _n_additions);
\\ return ret;
\\}
Expand Down Expand Up @@ -1426,7 +1426,7 @@ pub const RegisteredTypeInfoExt = struct {
}
}
} else {
try writer.print("const cFn = @extern(*const fn () callconv(.C) core.Type, .{{ .name = \"{s}\" }});\n", .{init_fn});
try writer.print("const cFn = @extern(*const fn () callconv(.c) core.Type, .{{ .name = \"{s}\" }});\n", .{init_fn});
try writer.writeAll("return cFn();\n");
}
try writer.writeAll("}\n");
Expand Down
Loading

0 comments on commit 9c3d9b4

Please sign in to comment.