ffi: conform load_enum to GLib 2.87.0 (via Arch Linux)

This commit is contained in:
ajacoutot
2026-05-11 06:07:36 +00:00
parent 7e9290a76d
commit 1c730b2cbb
2 changed files with 24 additions and 5 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ COMMENT= lua bindings to libraries using GObject-Introspection
GH_ACCOUNT= pavouk
GH_PROJECT= lgi
GH_TAGNAME= 0.9.2
REVISION= 0
REVISION= 1
PKGNAME= lua-${DISTNAME}
CATEGORIES= devel
+23 -4
View File
@@ -1,3 +1,8 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victoria Lacroix <victoria@vtrlx.ca>
Date: Wed, 4 Feb 2026 14:12:03 -0500
Subject: [PATCH] ffi: conform load_enum to GLib 2.87.0
From Arch Linux:
`ref` became unintrospectable in GLib 2.86
Use TypeClass.get instead of .ref
@@ -5,7 +10,12 @@ Use TypeClass.get instead of .ref
Index: lgi/ffi.lua
--- lgi/ffi.lua.orig
+++ lgi/ffi.lua
@@ -80,14 +80,13 @@ function ffi.load_enum(gtype, name)
@@ -76,18 +76,23 @@ end
-- Creates new enum/flags table with all values from specified gtype.
function ffi.load_enum(gtype, name)
- local GObject = core.repo.GObject
+ local GLib, GObject = core.repo.GLib, core.repo.GObject
local is_flags = GObject.Type.is_a(gtype, GObject.Type.FLAGS)
local enum_component = component.create(
gtype, is_flags and enum.bitflags_mt or enum.enum_mt, name)
@@ -13,9 +23,18 @@ Index: lgi/ffi.lua
+ local type_class = GObject.TypeClass.get(gtype)
local enum_class = core.record.cast(
type_class, is_flags and GObject.FlagsClass or GObject.EnumClass)
for i = 0, enum_class.n_values - 1 do
local val = core.record.fromarray(enum_class.values, i)
enum_component[core.upcase(val.value_nick):gsub('%-', '_')] = val.value
- for i = 0, enum_class.n_values - 1 do
- local val = core.record.fromarray(enum_class.values, i)
- enum_component[core.upcase(val.value_nick):gsub('%-', '_')] = val.value
+ if GLib.check_version(2, 87, 0) then
+ for i = 0, enum_class.n_values - 1 do
+ local val = core.record.fromarray(enum_class.values, i)
+ enum_component[core.upcase(val.value_nick):gsub('%-', '_')] = val.value
+ end
+ else
+ for _, val in ipairs(enum_class.values) do
+ enum_component[core.upcase(val.value_nick):gsub('%-', '_')] = val.value
+ end
end
- type_class:unref()
return enum_component