Skip to content

Commit 0a85c30

Browse files
committed
Fix some problems with GIRepository
1 parent 2afedf7 commit 0a85c30

File tree

5 files changed

+21
-30
lines changed

5 files changed

+21
-30
lines changed

LuaGObject/class.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ end
220220
function class.load_interface(namespace, info)
221221
-- Load all components of the interface.
222222
local interface = component.create(info, class.interface_mt)
223-
interface._name = info.name
224223
interface._property = load_properties(info)
225224
interface._method = component.get_category(info.methods, load_method)
226225
interface._signal = component.get_category(
@@ -241,9 +240,9 @@ end
241240

242241
function class.load_class(namespace, info)
243242
-- Find parent record, if available.
244-
local parent = info.parent
245-
if parent then
246-
local ns, name = parent.namespace, parent.name
243+
local parent_info, parent = info.parent
244+
if parent_info then
245+
local ns, name = parent_info.namespace, parent_info.name
247246
if ns ~= namespace._name or name ~= info.name then
248247
parent = core.repo[ns][name]
249248
end

LuaGObject/component.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ function component.get_category(children, xform_value,
6363
end
6464
end
6565

66+
-- The non-numeric indices still need to be iterated on, if any exist.
67+
for en, idx in pairs(index) do
68+
val = xvalue(children[idx])
69+
local name = not xform_name_reverse and en or xform_name_reverse(en)
70+
if name then category[name] = val end
71+
end
72+
6673
-- Metatable is no longer needed, disconnect it.
6774
return setmetatable(category, nil)
6875
end

LuaGObject/gi.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -464,19 +464,8 @@ info_index (lua_State *L)
464464
{
465465
if (strcmp (prop, "flags") == 0)
466466
{
467-
GParamFlags flags = gi_property_info_get_flags (GI_PROPERTY_INFO (*info));
468-
lua_newtable (L);
469-
#define H(n1) \
470-
if ((flags & G_PARAM_ ## n1) != 0) \
471-
{ \
472-
lua_pushboolean (L, 1); \
473-
lua_setfield (L, -2, #n1); \
474-
}
475-
H(READABLE)
476-
H(WRITABLE)
477-
H(CONSTRUCT)
478-
#undef H
479-
return 1;
467+
lua_pushinteger (L, gi_property_info_get_flags (GI_PROPERTY_INFO (*info)));
468+
return 1;
480469
}
481470
else if (strcmp (prop, "transfer") == 0)
482471
return

LuaGObject/marshal.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,21 @@ array_get_or_set_length (GITypeInfo *ti, gssize *get_length, gssize set_length,
184184

185185
if (GI_IS_FUNCTION_INFO (ci) || GI_IS_CALLBACK_INFO (ci))
186186
{
187-
GIArgInfo ai;
187+
GIArgInfo *ai;
188188

189189
if (param >= gi_callable_info_get_n_args (GI_CALLABLE_INFO (ci)))
190190
return;
191-
gi_callable_info_load_arg (GI_CALLABLE_INFO (ci), param, &ai);
192-
eti = gi_arg_info_get_type_info (&ai);
193-
/* Without explicitly incrementing the ref count on eti, it will be
194-
made into garbage when clearing ai. */
195-
gi_base_info_ref (eti);
196-
if (gi_arg_info_get_direction (&ai) == GI_DIRECTION_IN)
191+
ai = gi_callable_info_get_arg (GI_CALLABLE_INFO (ci), param);
192+
eti = gi_arg_info_get_type_info (ai);
193+
if (gi_arg_info_get_direction (ai) == GI_DIRECTION_IN)
197194
/* For input parameters, value is directly pointed to by args
198195
table element. */
199196
val = (GIArgument *) ((void **) args)[param];
200197
else
201198
/* For output arguments, args table element points to pointer
202199
to value. */
203200
val = *(GIArgument **) ((void **) args)[param];
204-
205-
gi_base_info_clear (&ai);
201+
gi_base_info_unref (ai);
206202
}
207203
else if (GI_IS_STRUCT_INFO (ci) || GI_IS_UNION_INFO (ci))
208204
{
@@ -507,9 +503,8 @@ marshal_2lua_array (lua_State *L, GITypeInfo *ti, GIDirection dir,
507503
{
508504
if (!gi_type_info_get_array_fixed_size (ti, (gsize *)&len))
509505
/* Length of the array is dynamic, get it from other
510-
argument. If the size isn't known ahead of time (it's -1),
511-
and it isn't zero-terminated, assume 1. */
512-
len = size < 0 ? 1 : size;
506+
argument. */
507+
len = size;
513508
}
514509
}
515510

LuaGObject/override/GObject-Object.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ function Object:_access_property(object, prop, ...)
279279
local gtype = Type.from_typeinfo(typeinfo)
280280
local marshaller = Value.find_marshaller(gtype, typeinfo,
281281
prop.transfer)
282-
return marshal_property(object, prop.name, prop.flags,
282+
return marshal_property(object, prop.name,
283+
repo.GObject.ParamFlags[prop.flags],
283284
gtype, marshaller, ...)
284285
else
285286
-- pspec-based property

0 commit comments

Comments
 (0)