Skip to content

Commit

Permalink
Fix gtype for Lua5.1 on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Mar 25, 2024
1 parent 5bc19cc commit b48405a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/vips/cdefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local ffi = require "ffi"

-- GType is an int the size of a pointer ... I don't think we can just use
-- size_t, sadly
if ffi.arch == "x64" then
if ffi.arch == "x64" and ffi.os ~= "Windows" then
ffi.cdef [[
typedef uint64_t GType;
]]
Expand Down
7 changes: 5 additions & 2 deletions src/vips/gvalue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ gvalue.blob_type = gobject_lib.g_type_from_name("VipsBlob")
gvalue.band_format_type = gobject_lib.g_type_from_name("VipsBandFormat")
gvalue.blend_mode_type = version.at_least(8, 6) and gobject_lib.g_type_from_name("VipsBlendMode") or 0

gvalue.comparable_type = type(gvalue.gdouble_type) == "number" and
function(gtype) return tonumber(gtype) end or
function(gtype) return gtype end
gvalue.to_enum = function(gtype, value)
-- turn a string into an int, ready to be passed into libvips
local enum_value
Expand Down Expand Up @@ -84,7 +87,7 @@ end

gvalue.set = function(gv, value)
local gtype_raw = gv.gtype
local gtype = tonumber(gtype_raw)
local gtype = gvalue.comparable_type(gtype_raw)
local fundamental = gobject_lib.g_type_fundamental(gtype_raw)

if gtype == gvalue.gbool_type then
Expand Down Expand Up @@ -156,7 +159,7 @@ end

gvalue.get = function(gv)
local gtype_raw = gv.gtype
local gtype = tonumber(gtype_raw)
local gtype = gvalue.comparable_type(gtype_raw)
local fundamental = gobject_lib.g_type_fundamental(gtype_raw)

local result
Expand Down
2 changes: 1 addition & 1 deletion src/vips/voperation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ end
voperation.set = function(self, name, flags, match_image, value)
local vob = self:vobject()
local gtype_raw = vob:get_typeof(name)
local gtype = tonumber(gtype_raw)
local gtype = gvalue.comparable_type(gtype_raw)

-- if the object wants an image and we have a constant, imageize it
--
Expand Down

0 comments on commit b48405a

Please sign in to comment.