Skip to content

Commit bce1f3f

Browse files
committed
Improve naming for gtype
1 parent 31f0287 commit bce1f3f

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

src/vips/gvalue.lua

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,27 @@ gvalue.init = function(gv, gtype)
8989
end
9090

9191
gvalue.set = function(gv, value)
92-
local gtype_raw = gv.gtype
93-
local gtype = gvalue.comparable_type(gtype_raw)
94-
local fundamental = gobject_lib.g_type_fundamental(gtype_raw)
92+
local gtype = gv.gtype
93+
local gtype_comp = gvalue.comparable_type(gtype)
94+
local fundamental = gobject_lib.g_type_fundamental(gtype)
9595

96-
if gtype == gvalue.gbool_type then
96+
if gtype_comp == gvalue.gbool_type then
9797
gobject_lib.g_value_set_boolean(gv, value)
98-
elseif gtype == gvalue.gint_type then
98+
elseif gtype_comp == gvalue.gint_type then
9999
gobject_lib.g_value_set_int(gv, value)
100-
elseif gtype == gvalue.gdouble_type then
100+
elseif gtype_comp == gvalue.gdouble_type then
101101
gobject_lib.g_value_set_double(gv, value)
102102
elseif fundamental == gvalue.genum_type then
103-
gobject_lib.g_value_set_enum(gv, gvalue.to_enum(gtype_raw, value))
103+
gobject_lib.g_value_set_enum(gv, gvalue.to_enum(gtype, value))
104104
elseif fundamental == gvalue.gflags_type then
105105
gobject_lib.g_value_set_flags(gv, value)
106-
elseif gtype == gvalue.gstr_type then
106+
elseif gtype_comp == gvalue.gstr_type then
107107
gobject_lib.g_value_set_string(gv, value)
108-
elseif gtype == gvalue.refstr_type then
108+
elseif gtype_comp == gvalue.refstr_type then
109109
gobject_lib.vips_value_set_ref_string(gv, value)
110-
elseif gtype == gvalue.image_type then
110+
elseif gtype_comp == gvalue.image_type then
111111
gobject_lib.g_value_set_object(gv, value.vimage)
112-
elseif gtype == gvalue.array_int_type then
112+
elseif gtype_comp == gvalue.array_int_type then
113113
if type(value) == "number" then
114114
value = { value }
115115
end
@@ -118,7 +118,7 @@ gvalue.set = function(gv, value)
118118
local a = ffi.new(gvalue.int_arr_typeof, n, value)
119119

120120
vips_lib.vips_value_set_array_int(gv, a, n)
121-
elseif gtype == gvalue.array_double_type then
121+
elseif gtype_comp == gvalue.array_double_type then
122122
if type(value) == "number" then
123123
value = { value }
124124
end
@@ -127,7 +127,7 @@ gvalue.set = function(gv, value)
127127
local a = ffi.new(gvalue.double_arr_typeof, n, value)
128128

129129
vips_lib.vips_value_set_array_double(gv, a, n)
130-
elseif gtype == gvalue.array_image_type then
130+
elseif gtype_comp == gvalue.array_image_type then
131131
if Image.is_Image(value) then
132132
value = { value }
133133
end
@@ -142,7 +142,7 @@ gvalue.set = function(gv, value)
142142
-- the gvalue needs a set of refs to own
143143
gobject_lib.g_object_ref(a[i])
144144
end
145-
elseif gtype == gvalue.blob_type then
145+
elseif gtype_comp == gvalue.blob_type then
146146
-- we need to set the blob to a copy of the lua string that vips
147147
-- can own
148148
local n = #value
@@ -156,27 +156,27 @@ gvalue.set = function(gv, value)
156156
vips_lib.vips_value_set_blob(gv, glib_lib.g_free, buf, n)
157157
end
158158
else
159-
error("unsupported gtype for set " .. gvalue.type_name(gtype_raw))
159+
error("unsupported gtype for set " .. gvalue.type_name(gtype))
160160
end
161161
end
162162

163163
gvalue.get = function(gv)
164-
local gtype_raw = gv.gtype
165-
local gtype = gvalue.comparable_type(gtype_raw)
166-
local fundamental = gobject_lib.g_type_fundamental(gtype_raw)
164+
local gtype = gv.gtype
165+
local gtype_comp = gvalue.comparable_type(gtype)
166+
local fundamental = gobject_lib.g_type_fundamental(gtype)
167167

168168
local result
169169

170-
if gtype == gvalue.gbool_type then
170+
if gtype_comp == gvalue.gbool_type then
171171
result = gobject_lib.g_value_get_boolean(gv)
172-
elseif gtype == gvalue.gint_type then
172+
elseif gtype_comp == gvalue.gint_type then
173173
result = gobject_lib.g_value_get_int(gv)
174-
elseif gtype == gvalue.gdouble_type then
174+
elseif gtype_comp == gvalue.gdouble_type then
175175
result = gobject_lib.g_value_get_double(gv)
176176
elseif fundamental == gvalue.genum_type then
177177
local enum_value = gobject_lib.g_value_get_enum(gv)
178178

179-
local cstr = vips_lib.vips_enum_nick(gtype_raw, enum_value)
179+
local cstr = vips_lib.vips_enum_nick(gtype, enum_value)
180180

181181
if cstr == ffi.NULL then
182182
error("value not in enum")
@@ -185,21 +185,21 @@ gvalue.get = function(gv)
185185
result = ffi.string(cstr)
186186
elseif fundamental == gvalue.gflags_type then
187187
result = gobject_lib.g_value_get_flags(gv)
188-
elseif gtype == gvalue.gstr_type then
188+
elseif gtype_comp == gvalue.gstr_type then
189189
local cstr = gobject_lib.g_value_get_string(gv)
190190

191191
if cstr ~= ffi.NULL then
192192
result = ffi.string(cstr)
193193
else
194194
result = nil
195195
end
196-
elseif gtype == gvalue.refstr_type then
196+
elseif gtype_comp == gvalue.refstr_type then
197197
local psize = ffi.new(gvalue.psize_typeof, 1)
198198

199199
local cstr = vips_lib.vips_value_get_ref_string(gv, psize)
200200

201201
result = ffi.string(cstr, tonumber(psize[0]))
202-
elseif gtype == gvalue.image_type then
202+
elseif gtype_comp == gvalue.image_type then
203203
-- g_value_get_object() will not add a ref ... that is
204204
-- held by the gvalue
205205
local vo = gobject_lib.g_value_get_object(gv)
@@ -211,7 +211,7 @@ gvalue.get = function(gv)
211211
gobject_lib.g_object_ref(vimage)
212212

213213
result = Image.new(vimage)
214-
elseif gtype == gvalue.array_int_type then
214+
elseif gtype_comp == gvalue.array_int_type then
215215
local pint = ffi.new(gvalue.pint_typeof, 1)
216216

217217
local array = vips_lib.vips_value_get_array_int(gv, pint)
@@ -220,15 +220,15 @@ gvalue.get = function(gv)
220220
result[i + 1] = array[i]
221221
end
222222

223-
elseif gtype == gvalue.array_double_type then
223+
elseif gtype_comp == gvalue.array_double_type then
224224
local pint = ffi.new(gvalue.pint_typeof, 1)
225225

226226
local array = vips_lib.vips_value_get_array_double(gv, pint)
227227
result = {}
228228
for i = 0, pint[0] - 1 do
229229
result[i + 1] = array[i]
230230
end
231-
elseif gtype == gvalue.array_image_type then
231+
elseif gtype_comp == gvalue.array_image_type then
232232
local pint = ffi.new(gvalue.pint_typeof, 1)
233233

234234
local array = vips_lib.vips_value_get_array_image(gv, pint)
@@ -243,14 +243,14 @@ gvalue.get = function(gv)
243243

244244
result[i + 1] = Image.new(vimage)
245245
end
246-
elseif gtype == gvalue.blob_type then
246+
elseif gtype_comp == gvalue.blob_type then
247247
local psize = ffi.new(gvalue.psize_typeof, 1)
248248

249249
local array = vips_lib.vips_value_get_blob(gv, psize)
250250

251251
result = ffi.string(array, tonumber(psize[0]))
252252
else
253-
error("unsupported gtype for get " .. gvalue.type_name(gtype_raw))
253+
error("unsupported gtype for get " .. gvalue.type_name(gtype))
254254
end
255255

256256
return result

src/vips/voperation.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ end
7272

7373
voperation.set = function(self, name, flags, match_image, value)
7474
local vob = self:vobject()
75-
local gtype_raw = vob:get_typeof(name)
76-
local gtype = gvalue.comparable_type(gtype_raw)
75+
local gtype = vob:get_typeof(name)
76+
local gtype_comp = gvalue.comparable_type(gtype)
7777

7878
-- if the object wants an image and we have a constant, imageize it
7979
--
8080
-- if the object wants an image array, imageize any constants in the
8181
-- array
8282
if match_image then
83-
if gtype == gvalue.image_type then
83+
if gtype_comp == gvalue.image_type then
8484
value = match_image:imageize(value)
85-
elseif gtype == gvalue.array_image_type then
85+
elseif gtype_comp == gvalue.array_image_type then
8686
for i = 1, #value do
8787
value[i] = match_image:imageize(value[i])
8888
end
@@ -96,7 +96,7 @@ voperation.set = function(self, name, flags, match_image, value)
9696
value = value:copy():copy_memory()
9797
end
9898

99-
return vob:set_type(name, value, gtype_raw)
99+
return vob:set_type(name, value, gtype)
100100
end
101101

102102
-- this is slow ... call as little as possible

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy