Check test coverage of signals

This commit is contained in:
Yevgen Muntyan 2011-01-21 21:19:18 -08:00
parent 201fa48a8d
commit 7a1ab202b2
2 changed files with 24 additions and 2 deletions

View File

@ -10,14 +10,16 @@ op.add_option("--output-lua", action="store")
lua_functions = []
python_functions = []
def walk(elm, lang, out):
def walk(elm, lang, out, cls=None):
if elm.get('moo.private') == '1' or elm.get('moo.' + lang) == '0':
return
if elm.tag in ('module', 'class', 'boxed', 'pointer', 'enum', 'flags'):
for child in elm.getchildren():
walk(child, lang, out)
walk(child, lang, out, elm.get('name'))
elif elm.tag in ('static-method', 'method', 'function', 'constructor'):
print >>out, elm.get('c_name')
elif elm.tag in ('signal'):
print >>out, '%s::%s' % (cls, elm.get('name'))
lua_out = open(opts.output_lua, 'w')
python_out = open(opts.output_python, 'w')

View File

@ -515,6 +515,9 @@ struct SignalClosure
lua_State *L;
GObject *instance;
int cb_ref;
#ifdef MOO_ENABLE_COVERAGE
char *signal_full_name;
#endif
};
static void signal_closure_finalize (G_GNUC_UNUSED gpointer dummy, GClosure *gclosure)
@ -701,6 +704,10 @@ signal_closure_marshal (SignalClosure *closure,
{
get_ret_gvalue (L, return_value);
lua_pop (L, 1);
#ifdef MOO_ENABLE_COVERAGE
moo_test_coverage_record ("lua", closure->full_signal_name);
#endif
}
else
{
@ -772,6 +779,19 @@ cfunc_GObject_connect_impl (gpointer pself, lua_State *L, int first_arg, gboolea
gulong cb_id = g_signal_connect_closure (self, signal, closure, after);
g_closure_unref (closure);
#ifdef MOO_ENABLE_COVERAGE
if (cb_id != 0)
{
GSignalQuery query;
g_signal_query (g_signal_lookup (signal, G_OBJECT_TYPE (self)), &query);
g_assert (query.signal_id != 0);
((SignalClosure*) closure)->signal_full_name =
g_strdup_printf ("%s::%s",
g_type_name (query.itype),
query.signal_name));
}
#endif
moo_lua_push_int (L, cb_id);
return 1;
}